﻿package plugin.taskdialog.component
{
    import com.core.*;
    import com.sh.game.global.*;
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    import morn.core.components.*;
    import plugin.component.*;
    import vo.*;

    public class NewRewardListItem extends Sprite
    {
        private var item:FlashItem;
        private var _counttxt:Label;
        private var Data:Object;

        public function NewRewardListItem()
        {
            if (!this._counttxt)
            {
                this._counttxt = new Label();
                this._counttxt.width = 160;
                this._counttxt.height = 20;
                this._counttxt.align = "left";
                this._counttxt.mouseEnabled = false;
                this._counttxt.x = 50;
                this._counttxt.y = 20;
                this._counttxt.color = 16636570;
                this.addChild(this._counttxt);
            }
            return;
        }// end function

        public function get data() : Object
        {
            return this.Data;
        }// end function

        public function set data(param1:Object) : void
        {
            var _loc_2:String = null;
            var _loc_3:int = 0;
            this.Data = param1;
            if (!this.item)
            {
                this.item = new FlashItem(param1, 0.6, false, false, null, false, true);
                this.item.x = 0;
                this.item.y = 0;
                this.item.addEventListener(MouseEvent.ROLL_OVER, this.onOver);
                this.item.addEventListener(MouseEvent.ROLL_OUT, this.onOut);
                this.addChild(this.item);
            }
            if (this.data.count > 0)
            {
                _loc_2 = this.data.count;
                if (this.data.count > 10000)
                {
                    _loc_2 = this.data.count / 10000 + "万";
                }
                if (this.data.itemtype != 1)
                {
                    _loc_3 = ModelProxy.getValue("data", "bag.fcmstate");
                    if (_loc_3 == 0)
                    {
                        this._counttxt.text = this.data.name + "：" + _loc_2;
                    }
                    else if (_loc_3 == 1)
                    {
                        this._counttxt.text = this.data.name + "：" + _loc_2;
                    }
                    else
                    {
                        this._counttxt.text = "0(零)";
                    }
                }
                else
                {
                    this._counttxt.text = this.data.name + "：" + _loc_2;
                }
                this._counttxt.visible = true;
            }
            else
            {
                this._counttxt.visible = false;
            }
            return;
        }// end function

        protected function onOver(event:MouseEvent) : void
        {
            var _loc_2:Object = null;
            this.removeEventListener(MouseEvent.MOUSE_OVER, this.onOver);
            if (this.data.itemtype == 1)
            {
                _loc_2 = ItemObject.create(this.data);
                _loc_2.wear = 0;
                ModelProxy.change("tips", "arm", {data:_loc_2, p:new Point(GlobalLayer.instance.flashStage.mouseX, GlobalLayer.instance.flashStage.mouseY)});
            }
            else if (this.data.itemtype == 2)
            {
                _loc_2 = ItemObject.create(this.data);
                ModelProxy.change("tips", "tool", {data:_loc_2, p:new Point(GlobalLayer.instance.flashStage.mouseX, GlobalLayer.instance.flashStage.mouseY)});
            }
            this.addEventListener(MouseEvent.MOUSE_OUT, this.onOut);
            return;
        }// end function

        protected function onOut(event:MouseEvent) : void
        {
            this.removeEventListener(MouseEvent.MOUSE_OUT, this.onOut);
            ModelProxy.change("tips", "state", "close");
            this.addEventListener(MouseEvent.MOUSE_OVER, this.onOver);
            return;
        }// end function

        public function dispose() : void
        {
            if (this.item)
            {
                this.item.dispose();
                this.item = null;
            }
            if (this._counttxt && this._counttxt.parent)
            {
                this._counttxt.parent.removeChild(this._counttxt);
                this._counttxt = null;
            }
            return;
        }// end function

    }
}
